package com.mxt.moviedemo.dao;

import com.mxt.moviedemo.entity.Ticket;
import com.mxt.moviedemo.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {
    @Insert("INSERT INTO ticket(tid, uuid, uname, mname, price, count, totalprice, otime) " +
            "VALUES(#{tid}, #{uuid}, #{uname}, #{mname}, #{price}, #{count}, #{totalprice}, #{otime})")
    void save(Ticket ticket);

    @Select("SELECT * FROM ticket WHERE tid = #{tid}")
    Ticket findByTid(String tid);

    @Select("SELECT * FROM ticket WHERE uuid = #{uuid}")
    List<Ticket> findByUuid(String uuid);

    @Select("SELECT * FROM ticket")
    List<Ticket> findAll();

    @Update("UPDATE ticket SET mname=#{mname}, price=#{price}, count=#{count}, totalprice=#{totalprice} WHERE tid=#{tid}")
    void update(Ticket ticket);

    @Delete("DELETE FROM ticket WHERE tid = #{tid}")
    void delete(String tid);
}
